<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>location地址栏对象</title>
    <style>
        p {
            text-align: center;
        }

        span {
            color: red;
        }
    </style>
</head>

<body>
    <p>
        注册成功！<span id="time">3</span>秒之后自动跳转到首页...
    </p>

    <script>
        let timeOut = 3;
        //定义定时器,红色数字要变化
        let time = setInterval(function () {
            document.getElementById("time").innerHTML = timeOut;
            if (timeOut === 0) {
                location.href = 'http://www.baidu.com';
            }
            timeOut--;
            //修改文本属性
        }, 1000);

    </script>
</body>

</html>